//
//  loginViewController.m
//  TinyFortune
//
//  Created by lc on 16/5/25.
//  Copyright © 2016年 lc. All rights reserved.
//

#import "loginViewController.h"
#import "RegisterViewController.h"
#import "reloginViewController.h"
@interface loginViewController ()

@end

@implementation loginViewController

#pragma  mark - createUI
- (void)createUI{

    [self.navigationController setNavigationBarHidden:YES];
    //背景图
    UIImageView *bg = [[UIImageView alloc]initWithFrame:self.view.bounds];
    bg.image = [UIImage imageNamed:@"bgg2.jpg"];
    [self.view addSubview:bg];
    CGFloat X = self.view.frame.size.width/4.0f;
    CGFloat Y = self.view.frame.size.height * 3/5.0f;
    CGFloat W = 50;
    CGFloat H = 50;
    CGFloat marginx = 15;
    CGFloat marginY = 60;
    //qq登录
    UIButton *qqbutton = [[UIButton alloc]initWithFrame:CGRectMake(X, Y, W, H)];
    [qqbutton setImage:[[UIImage imageNamed:@"qq-icon"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
   // [self.view addSubview:qqbutton];
    //微信登录
    UIButton *wechatButton = [[UIButton alloc]initWithFrame:CGRectMake(marginx + qqbutton.frame.size.width + qqbutton.frame.origin.x, qqbutton.frame.origin.y, W, H)];
    [wechatButton setImage:[[UIImage imageNamed:@"wechat-icon"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
   // [self.view addSubview:wechatButton];
    //微博登录
    UIButton *sinaButton = [[UIButton alloc]initWithFrame:CGRectMake(marginx + wechatButton.frame.size.width + wechatButton.frame.origin.x, wechatButton.frame.origin.y, W, H)];
    [sinaButton setImage:[[UIImage imageNamed:@"sina-icon"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
   // [self.view addSubview:sinaButton];
    //一般登录
    CGFloat WW = (3 * W + 3 * marginx)/2.0f;
    UIButton *logging = [[UIButton alloc]initWithFrame:CGRectMake(qqbutton.frame.origin.x, qqbutton.frame.origin.y + marginY, WW, H)];
    [logging setTitle:@"登录" forState:UIControlStateNormal];
    [logging setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [logging.layer setCornerRadius:10];
    logging.layer.masksToBounds = YES;
    logging.layer.borderColor = [UIColor whiteColor].CGColor ;
    logging.layer.borderWidth = 1;
    [logging addTarget:self action:@selector(logging) forControlEvents:UIControlEventTouchDown];
    [self.view addSubview:logging];
    
    //手机注册
    UIButton *registerButton = [[UIButton alloc]initWithFrame:CGRectMake(logging.frame.origin.x + logging.frame.size.width + 5, qqbutton.frame.origin.y + marginY, WW, H)];
    [registerButton setTitle:@"注册" forState:UIControlStateNormal];
    [registerButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [registerButton.layer setCornerRadius:10];
    registerButton.layer.masksToBounds = YES;
    registerButton.layer.borderColor = [UIColor whiteColor].CGColor ;
    registerButton.layer.borderWidth = 1;
    [registerButton addTarget:self action:@selector(registerButton) forControlEvents:UIControlEventTouchDown];
    [self.view addSubview:registerButton];
    
    //增加滑动手势
    UISwipeGestureRecognizer *swip = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(cancel:)];
    [self.view addGestureRecognizer:swip];
}
#pragma mark -登录/注册按钮的点击事件
- (void)logging{
    
    reloginViewController *relogin = [reloginViewController new];
    [self.navigationController pushViewController:relogin animated:YES];
    
}
- (void)registerButton{
    RegisterViewController *registerVC = [RegisterViewController new];
    
    [self.navigationController pushViewController:registerVC animated:YES];
}
#pragma  mark - 滑动手势
- (void)cancel:(UISwipeGestureRecognizer *)sender{
    [self dismissViewControllerAnimated:YES completion:nil];
}
#pragma  mark - 生命周期
- (void)viewDidLoad {
    [super viewDidLoad];
    [self createUI];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES];

}
@end
